package com.stars.distributed.schedule.demo.demo;

import com.stars.distributed.schedule.ScheduleTask;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 批量框架实现类DEMO
 *
 * @author GUOGUIFANG
 */
@ScheduleTask("demoTask1")
public class TaskDemo1 implements Job {

    private static final Logger logger = LoggerFactory.getLogger(TaskDemo.class);

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        int partitionCount = (int) jobExecutionContext.get("partitionCount");
        int index = (int) jobExecutionContext.get("partitionIndex");

        System.out.println(partitionCount + ":" + index);
        logger.info("{} -- springBoot -- demoTask1- 开始执行: ,partition number{},partition count: {}",Thread.currentThread().getName() , partitionCount,index);
        try {
            Thread.sleep(30000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        logger.info("{} -- springBoot -- demoTask1 完成执行: ,partition number{},完成时间:{}" ,Thread.currentThread().getName() ,index, System.currentTimeMillis());
    }
}
